package com.movie.ticket.sale.authorassembly.dao;

import com.movie.ticket.sale.moviecommon.model.TCinema;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Options;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

/**
 * <p>
 * Mapper 接口
 * </p>
 *
 * @author Ticket
 * @since 2020-12-08
 */
public interface TCinemaMapper extends BaseMapper<TCinema> {

    @Options(useGeneratedKeys = true, keyProperty = "id")
    @Insert("insert into t_cinema(role,password,tel,name,cinema_name,state,degree,tip_root,illegal) values(#{role},#{password},#{tel},#{name},#{cinemaName},#{state},#{degree},#{tipRoot},0)")
    void addNewCinema(TCinema cinema);

    @Update("update t_cinema set account=#{account},cinema_name=#{cinemaName},legal_person=#{legalPerson},lp_id_number=#{lpIdNumber},degree=#{degree},register_number=#{registerNumber},state=#{state},chain=#{chain} where id=#{id} and state=-9")
    void addRegisterLegalMessage(TCinema cinema);

    @Select("select * from t_cinema where tel=#{tel}")
    TCinema getCinemaByTel(String oldTel);

    @Update("update t_cinema set address=#{address},longitude=#{longitude},latitude=#{latitude},service=#{service},state=#{state} where id=#{id} and state=-8")
    void addRegisterCinemaMessage(TCinema cinema);

    @Update("update t_cinema set state=#{state} where id=#{id}")
    void changeContractSetState(@Param("id")int id,@Param("state")int state);

    @Update("update t_cinema set annual_cost=#{annual},tip_root=#{tip} where id=#{id} and state=-7")
    void changeAnnualCostAndTipRoot(@Param("id")int id, @Param("annual")double i, @Param("tip")double v);

    @Select("select * from t_cinema where degree=1")
    List<TCinema> findAllCinemaFather();
}
